<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			html, body{
				height: 100%;
				overflow: hidden;
			}
			#canvas{
				position: absolute;
				left: 0;
				right: 0;
				top: 0;
				bottom: 0;
				margin: auto;
				background: pink;
				
			}
		</style>
		<script>
			window.onload = function(){
				var canvas = document.getElementById("canvas");
				
				if(canvas.getContext){
					var ctx = canvas.getContext("2d")
					
					var img = new Image()
					img.src = "../../img/wechat.jpg"
					img.onload = function(){
						draw()
					}
					
					function draw(){
						// 径向渐变
						var gradient = ctx.createRadialGradient(150, 150, 50, 150, 150, 30)
						
						gradient.addColorStop(0, "red")
						gradient.addColorStop(0.5, "yellow")
						gradient.addColorStop(0.7, "blue")
						gradient.addColorStop(1, "green")
						
						ctx.fillStyle = gradient
						ctx.fillRect(0, 0, 300, 300)
	 					
						// 使用渐变
//						var gradient = ctx.createLinearGradient(0, 0, 150, 150)
//						gradient.addColorStop(0, "red")
//						gradient.addColorStop(0.5, "yellow")
//						gradient.addColorStop(0.7, "blue")
//						gradient.addColorStop(1, "green")
//						
//						ctx.fillStyle = gradient
//						ctx.fillRect(0, 0, 250, 250)
						
						// 设置背景
						// var pattern = ctx.createPattern(img, "no-repeat")
						// ctx.fillStyle = pattern
						// ctx.fillRect(0, 0, 200, 200)
						
						// 引入图片
						// ctx.drawImage(img, 100, 100, img.width, img.height)
					}
				}
			}
		</script>
	</head>
	<body>
		<canvas id="canvas" width="300px" height="300px">
			<span><a href="39.108.121.57:8080">您的浏览器不支持画布元素, 请您换成萌萌的chrome浏览器</a></span>
		</canvas>
	</body>
</html>
